<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="">
		操作数1：<input type="text" name="c1" value=""/><br />
		操作数2：<input type="text" name="c2" value=""/><br />
		请选择相应的运算<hr />
		<div>
			<input type="radio" name="zy" value="1">加<br />
			<input type="radio" name="zy" value="2">减<br />
			<input type="radio" name="zy" value="3">乘<br />
			<input type="radio" name="zy" value="4">除<br />
		</div>
		<hr />
		<div>
			<input type="submit" value="计算">
			<input type=reset value="清除">
		</div>
	</form>
	<hr />
	<%
		String q1 = request.getParameter("c1");
		String q2 = request.getParameter("c2");
		String zy = request.getParameter("zy");
		double c1,c2;
		double result = 0;
		String fuhao = "";
		if(zy != null && zy.length() > 0) {
			if(q1 != null && q1.length() > 0)
				c1 = Double.parseDouble(q1);
			else
				c1 = 0;
			if(q2 != null && q2.length() > 0)
				c2 = Double.parseDouble(q2);
			else
				c2 = 0;
			int zys = Integer.parseInt(zy);
			switch(zys) {
				case 1:result = c1 + c2;
					fuhao = "+";
					break;
				case 2:result = c1 - c2;
					fuhao = "-";
					break;
				case 3:result = c1 * c2;
					fuhao = "*";
					break;
				case 4:result = c1 / c2;
					fuhao = "/";
					break;
				default:result = 0;
			}
			out.print(c1 + fuhao + c2 + "=" + result);
		}
	%>
</body>
</html>